<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{lib/layui-v2.5.5/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{css/public.css}" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
    <script th:src="@{js/axios.js}"></script>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">歌曲编号</label>
        <div class="layui-input-block">
            <input type="number" name="song_id" lay-verify="required" lay-reqtext="歌曲编号不能为空" placeholder="请输入歌曲编号" value="" class="layui-input">
            <tip>填写歌曲的id</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">歌曲名字</label>
        <div class="layui-input-block">
            <input type="text" name="song_name" lay-verify="required" lay-reqtext="歌曲名字不能为空" placeholder="请输入歌曲名字" value="" class="layui-input">
            <tip>填写歌曲的name</tip>
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required"></label>
        <div class="layui-input-block">
            <input type="radio" name="type" value="华语" title="华语" checked="true">
            <input type="radio" name="type" value="流行" title="流行">
            <input type="radio" name="type" value="摇滚" title="摇滚" >
            <input type="radio" name="type" value="民谣" title="民谣">
            <input type="radio" name="type" value="电子" title="电子">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">图片地址</label>
        <div class="layui-input-block">
            <input type="text" name="picture_address" lay-verify="required" lay-reqtext="图片地址不能为空" placeholder="请输入图片地址" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">音乐地址</label>
        <div class="layui-input-block">
            <input type="text" name="music_address" lay-verify="required" lay-reqtext="音乐地址不能为空" placeholder="请输入音乐地址" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">视频地址</label>
        <div class="layui-input-block">
            <input type="text" name="video_address"   placeholder="请输入视频地址" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">歌手名字</label>
        <div class="layui-input-block">
            <input type="text" name="singer_name" lay-verify="required" lay-reqtext="歌手名字不能为空" placeholder="请输入歌手名字" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">歌曲上架日期</label>
        <div class="layui-input-block">
            <input type="date" name="date" lay-verify="required" lay-reqtext="上架日期不能为空" placeholder="请输入上架日期" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">点赞数目</label>
        <div class="layui-input-block">
            <input type="number" name="like_number" lay-verify="required" placeholder="请输入点赞数目" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">播放次数</label>
        <div class="layui-input-block">
            <input type="number" name="amount_of_play" lay-verify="required" placeholder="请输入播放次数" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">收藏量</label>
        <div class="layui-input-block">
            <input type="number" name="collected" lay-verify="required" placeholder="请输入收藏量" value="" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">歌曲描述</label>
        <div class="layui-input-block">
            <textarea name="song_describing" class="layui-textarea" placeholder="请输入歌曲描述"></textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">歌词</label>
        <div class="layui-input-block">
            <textarea name="lyrics" class="layui-textarea" placeholder="请输入歌词"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script th:src="@{lib/layui-v2.5.5/layui.js}" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var song = data.field;

            axios.post("/admin/addsong", {
                song_id:song.song_id,
                song_name:song.song_name,
                song_describing:song.song_describing,
                picture_address:song.picture_address,
                music_address:song.music_address,
                video_address:song.video_address,
                singer_name:song.singer_name,
                date:song.date,
                lyrics:song.lyrics,
                like_number:song.like_number,
                amount_of_play:song.amount_of_play,
                type:song.type,
                collected:song.collected,
            }).then(function (response) {

                }
            )
            var index = layer.alert(JSON.stringify(data.field.song_name+"添加成功"), {
                title: '最终的提交信息'
            }, function () {

                // 关闭弹出层
                layer.close(index);

                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);

            });

            return false;
        });

    });
</script>
</body>
</html>